#ifndef __DALELIB_SHADER_H__
#define __DALELIB_SHADER_H__

#include <map>
#include <string>
#include <dalelib/graphics.h>
#include <CG/cg.h>
#include <CG/cggl.h>
#include <dalelib/maths/v2.h>
#include <dalelib/maths/v3.h>
#include <dalelib/maths/v4.h>
#include <dalelib/maths/m4.h>

using namespace std;

namespace dalelib
{

class Shader
{
private:

	CGprogram _vert_program;
	CGprogram _frag_program;
	std::map<std::string,CGparameter> _params;

public:

	Shader()
		: _vert_program(NULL)
		, _frag_program(NULL)
	{ }
	~Shader() { }

	void load(string _ShaderName);
	void loadVertProgram(string _Name);
	void loadFragProgram(string _Name);
	void addVertParam(string _Name);
	void addFragParam(string _Name);
	void bind();
	void unbind();
	void setParam(string _Param, float _Value0);
	void setParam(string _Param, int _Value0);
	void setParam(string _Param, float _Value0, float _Value1);
	void setParam(string _Param, v2 _Value);
	void setParam(string _Param, float _Value0, float _Value1, float _Value2);
	void setParam(string _Param, v3 _Value);
	void setParam(string _Param, float _Value0, float _Value1, float _Value2, float _Value3);
	void setParam(string _Param, v4 _Value);
	void setParamArray1(std::string _Param, const int _Num, float* _Data);
	void setParamArray2(std::string _Param, const int _Num, float* _Data);
	void setParamArray3(std::string _Param, const int _Num, float* _Data);
	void setParamArray4(std::string _Param, const int _Num, float* _Data);
	void setParamMatrix(std::string _Param, CGGLenum _Value0, CGGLenum _Value1);
	void setParamMatrix(std::string _Param, m4 _Matrix);
	void setParamTex(string _Param, GLuint _Texture);
	bool paramExists(string _Param);

};

} // namespace dalelib

#endif
